﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Collections.ObjectModel;

namespace WPFTest
{
    class OzProject : ObservableCollection<OzFrame>
    {
        #region FIELDS

        private string projectName;
        //private List<OzFrame> frames;
        private string outFolder;

        #endregion

        #region PROPERTIES

        public string ProjectName
        {
            get { return this.projectName; }
            set { this.projectName = value; }
        }

        public string OutFolder
        {
            get { return this.outFolder; }
            set { this.outFolder = value; }
        }

        #endregion
        
        #region CONSTRUCTORS   

        public OzProject(string name)
        {
            ProjectName = name;
            //frames = new List<OzFrame>();
        }

        #endregion

        #region METHODS

        public void GenerateHTML()
        {
            TextWriter writer = new StreamWriter(outFolder + "index.html");

            #region HTML
            writer.WriteLine("<html>");
            writer.WriteLine("<head>");
            #region HEAD
            writer.WriteLine("<title>" + ProjectName + "</title>");
            writer.WriteLine("<link href='stylesheet_default.css' rel='stylesheet' type='text/css' />");
            #endregion
            writer.WriteLine("</head>");
            writer.WriteLine("<body class='class_body'><div id='class_main'>");
            #region BODY

            writer.WriteLine("<div id='header'>");
            writer.WriteLine(ProjectName);
            writer.WriteLine("</div>");

            for (int i = 0; i < this.Count; i++)
            {
                OzFrame frame = this[i] as OzFrame;
                frame.Write(writer,i, outFolder);
            }

            writer.WriteLine("<div id='footer'>");
            writer.WriteLine("OzTut copyright 2012.");
            writer.WriteLine("</div>");

            #endregion
            writer.WriteLine("</div></body>");
            writer.WriteLine("</html>");
            #endregion

            writer.Close();
        }

        //public void AddFrame(OzFrame newFrame)
        //{
        //    frames.Add(newFrame);
        //}

        #endregion


    }
}
